package com.lovo.dao;

import com.lovo.model.UserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.persistence.LockModeType;
import java.util.List;

public interface UserDAO extends JpaRepository<UserDO,Integer> {
    @Lock(LockModeType.PESSIMISTIC_WRITE)
    UserDO findByNameAndPwd(String name,String pwd);

    @Query("from UserDO where name = ?1")
    List findCondition(String name);

    @Modifying
    @Query("delete from UserDO where name = ?1")
    void deleteByName(String name);

}
